import type { DaDropdownMenuListItem } from '../../../filter/typing'
export function paramsAdapter(params: Recordable) {
  const _params = { ...params }
  if (params.SortOrder) {
    _params.SortOrder = params.SortOrder == 'desc' ? 0 : 1
  } else if (params.DateRange) {
    _params.StartDate = params.DateRange.start
    _params.EndDate = params.DateRange.end
    delete _params.DateRange
  }
  return _params
}
export function dataSynchronization(
  data: Recordable,
  schemas: DaDropdownMenuListItem[]
) {
  schemas.forEach((item) => {
    if (Reflect.has(data, item.prop)) {
      item.value = data[item.prop]
    }
  })
}
